package com.huawei.appgallery.purchasehistory.ui.fragment;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.huawei.appgallery.foundation.ui.framework.uikit.ContractFragment;
import com.huawei.appgallery.foundation.ui.framework.widget.NetworkRemindBar;
import com.huawei.appgallery.foundation.ui.framework.widget.NetworkRemindBar.c;
import com.huawei.appgallery.foundation.ui.framework.widget.NodataWarnLayout;
import com.huawei.appgallery.foundation.ui.framework.widget.PullUpListView;
import com.huawei.appgallery.foundation.ui.framework.widget.PullUpListView.a;
import com.huawei.appgallery.productpurchase.api.ProductDetailBean;
import com.huawei.appgallery.purchasehistory.api.AppTracesListFragmentProtocol;
import com.huawei.appgallery.purchasehistory.ui.adapter.ProductAdapter;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import o.cip;
import o.crg;
import o.crm;
import o.csp;
import o.cst.d;
import o.cst.e;
import o.cst.h;
import o.doo;
import o.CollectCheck;
import o.eqp;
import o.fho;
import org.jetbrains.annotations.NotNull;

public class ProductFragment<T extends AppTracesListFragmentProtocol> extends ContractFragment implements a, c {
    private b ʹ;
    private crg ʼ;
    private NetworkRemindBar ʽ;
    private Context ˊ;
    private List<ProductDetailBean> ˋ = new ArrayList();
    private PullUpListView ˎ;
    private ProductAdapter ˏ;
    private int ॱ = 1;
    private int ॱॱ;
    private NodataWarnLayout ᐝ;
    private LinearLayout ﾞ;
    private cip ﾟ;

    static class b implements crm {
        private WeakReference<ProductFragment> ˋ;

        private b(ProductFragment productFragment) {
            this.ˋ = new WeakReference(productFragment);
        }

        public void ˎ(int i, int i2, int i3, List<ProductDetailBean> list) {
            ProductFragment productFragment = (ProductFragment) this.ˋ.get();
            if (productFragment == null) {
                csp.ˏ.ˏ("ProductFragment", "fragment = null");
            } else if (productFragment.ˎ == null) {
                csp.ˏ.ˏ("ProductFragment", "listView = null");
            } else if (doo.ˊ(productFragment.ˊ)) {
                productFragment.ﾞ.setVisibility(0);
                if (productFragment.ˎ(i, i2)) {
                    productFragment.ﾟ.onEvent(0);
                    productFragment.ʽˊ();
                } else if (productFragment.ﾟ != null) {
                    productFragment.ﾟ.onEvent(i);
                    productFragment.ﾟ = null;
                } else {
                    productFragment.ˋ(i);
                }
                productFragment.ॱॱ = i3;
                if (i3 == 1) {
                    ProductFragment.ʽ(productFragment);
                } else if (productFragment.ˎ.ˊॱ() != null) {
                    productFragment.ˎ.ˊॱ().setVisibility(8);
                }
                if (eqp.ᐝ()) {
                    productFragment.ˋ.addAll(list);
                } else {
                    productFragment.ˋ = new ArrayList();
                }
                if (CollectCheck.isEmpty(productFragment.ˋ)) {
                    csp.ˏ.ˋ("ProductFragment", "no data");
                    productFragment.ˎ.setEmptyView(productFragment.ʾॱ());
                }
                productFragment.ॱ();
                productFragment.ˏ.setHasNext(i3);
            } else {
                productFragment.ﾟ.ˏ(i, true);
                productFragment.ﾞ.setVisibility(8);
                csp.ˏ.ˏ("ProductFragment", "no network");
            }
        }
    }

    static /* synthetic */ int ʽ(ProductFragment productFragment) {
        int i = productFragment.ॱ + 1;
        productFragment.ॱ = i;
        return i;
    }

    public void ॱ(@NotNull Context context) {
        super.ॱ(context);
        this.ˊ = context;
    }

    public View ˋ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        ViewGroup viewGroup2 = (ViewGroup) layoutInflater.inflate(d.ˋॱ, viewGroup, false);
        this.ᐝ = (NodataWarnLayout) viewGroup2.findViewById(e.ˑ);
        this.ʽ = (NetworkRemindBar) viewGroup2.findViewById(e.ˎˎ);
        this.ˎ = (PullUpListView) viewGroup2.findViewById(e.ॱˊ);
        this.ﾞ = (LinearLayout) viewGroup2.findViewById(e.ˈ);
        this.ﾟ = new cip(true);
        viewGroup2.addView(this.ﾟ.ˏ(layoutInflater), 0);
        this.ﾟ.ˋ(new OnClickListener(this) {
            final /* synthetic */ ProductFragment ˋ;

            {
                this.ˋ = r1;
            }

            public void onClick(View view) {
                this.ˋ.ʼᐝ();
            }
        });
        this.ﾟ.ˏ();
        this.ʼ = (crg) fho.ˏ().ˋ("ProductPurchase").ॱ(crg.class);
        this.ʼ.ˎ();
        this.ʹ = new b();
        this.ʼ.ˊ(this.ॱ, 25, this.ʹ);
        this.ˎ.setLoadingListener(this);
        this.ʽ.setNetworkRemindBarListener(this);
        this.ʽ.ˋ();
        return viewGroup2;
    }

    private void ॱ() {
        if (this.ˏ == null) {
            this.ˏ = new ProductAdapter(this.ˊ, this.ˋ, this.ॱॱ);
            this.ˎ.setAdapter(this.ˏ);
        }
        this.ˏ.notifyDataSetChanged();
    }

    public void ʽᐝ() {
        csp.ˏ.ˋ("ProductFragment", "onLoadingMore");
        this.ˎ.ʻ();
        this.ʼ.ˊ(this.ॱ, 25, this.ʹ);
    }

    public void ʼᐝ() {
        csp.ˏ.ˋ("ProductFragment", "onLoadingRetry");
        this.ˎ.ʻ();
        this.ʼ.ˊ(this.ॱ, 25, this.ʹ);
    }

    public void ˈॱ() {
    }

    public void ˊʼ() {
    }

    public void ʿॱ() {
    }

    public void ﾟॱ() {
        if (this.ﾟ != null) {
            this.ﾟ.ˊ();
        }
        ʼᐝ();
    }

    public void ﹶ() {
    }

    public void ʳ() {
    }

    private View ʾॱ() {
        this.ᐝ.setWarnImage(o.cst.b.ˊ);
        this.ᐝ.setWarnTextOne(h.ˋॱ);
        this.ᐝ.setViewVisible(NodataWarnLayout.e.WARN_BTN, 8);
        this.ᐝ.setViewVisible(NodataWarnLayout.e.WARN_TEXTTWO, 8);
        return this.ᐝ;
    }

    private void ˋ(int i) {
        if (this.ʽ == null) {
            return;
        }
        if (3 == i) {
            this.ʽ.ॱ();
        } else {
            this.ʽ.ˏ();
        }
    }

    private void ʽˊ() {
        if (this.ʽ != null) {
            this.ʽ.setNetworkOK();
        }
    }

    private boolean ˎ(int i, int i2) {
        return i == 0 && i2 == 0;
    }
}
